<?php
namespace common\forms\login;

use Yii;
use yii\base\ModelEvent;
use heihei\auth\JwtAuth;
use yii\base\InvalidValueException;

/**
 * 登陆表单
 */
class JwtLoginForm extends BaseLoginForm
{
    /**
     * 获取JWT TOKEN.
     *
     * @return User|null the saved model or null if saving fails
     */
    public function getJwtToken()
    {
        if(!($user = $this->getUser())){
            throw new InvalidValueException("获取登陆信息失败！");            
        }
        $userData = [
            'uid' => $user->id
        ];

        return Yii::$app->securityJwt->encode($userData);
    }


    public function login($type = 'default')
    {
        $user = parent::login($type);
        
    }
}
